home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 426-450 / disk_438 / toollib / source / library.s < prev    next >
Text File  |  1992-05-06  |  7KB  |  307 lines

  1.         opt     l+,o+,ow-
  2. *
  3. *   library.s version 7.6 - © Copyright 1990 Jaba Development
  4. *
  5. *   Author    : Jan van den Baard
  6. *   Assembler : Devpac version 2.14
  7. *
  8.         incdir  'sys:devpac_inc/'
  9.         include 'exec/types.i'
  10.         include 'exec/initializers.i'
  11.         include 'exec/alerts.i'
  12.         include 'exec/io.i'
  13.         include 'exec/libraries.i'
  14.         include 'exec/resident.i'
  15.         include 'exec/strings.i'
  16.         include 'exec/exec_lib.i'
  17.         include 'libraries/dos.i'
  18.         include 'libraries/dos_lib.i'
  19.         include 'mymacros.i'
  20.  
  21.         STRUCTURE   ToolBase,LIB_SIZE
  22.         APTR        tb_SysBase
  23.         APTR        tb_DOSBase
  24.         APTR        tb_IntuitionBase
  25.         APTR        tb_GfxBase
  26.         ULONG       tb_SegList
  27.         LABEL       tb_SIZEOF
  28.  
  29. VERSION     EQU     7
  30. REVISION    EQU     6
  31.  
  32.         xref    CreatePort
  33.         xref    DeletePort
  34.         xref    CreateExtIO
  35.         xref    DeleteExtIO
  36.         xref    CreateStdIO
  37.         xref    DeleteStdIO
  38.         xref    CreateTimeDelay
  39.         xref    DoTimeDelay
  40.         xref    DeleteTimeDelay
  41.  
  42.         xref    QuickSort
  43.         xref    SwapMem
  44.  
  45.         xref    TestBits
  46.         xref    SelectGadget
  47.         xref    DeSelectGadget
  48.         xref    MutualExclude
  49.         xref    MutualInclude
  50.         xref    EraseGadget
  51.         xref    GadgetOn
  52.         xref    GadgetOff
  53.         xref    SelectTest
  54.         xref    ShadowGadget
  55.         xref    OnGList
  56.         xref    OffGList
  57.         xref    SelectGList
  58.         xref    DeSelectGList
  59.         xref    ShadowGList
  60.         xref    EraseGList
  61.  
  62.         xref    InitMemoryChain
  63.         xref    AllocItem
  64.         xref    FreeItem
  65.         xref    FreeMemoryChain
  66.  
  67.         xref    Format
  68.         xref    WriteFormat
  69.         xref    MatchPattern
  70.         xref    Isolate
  71.         xref    BstrToCstr
  72.         xref    GetDate
  73.  
  74.         xref    OpenDir
  75.         xref    GetEntry
  76.         xref    CloseDir
  77.         xref    FreeDir
  78.         xref    IoErrToStr
  79.  
  80.         xref    AllocFreq
  81.         xref    FreeFreq
  82.         xref    FileRequest
  83.  
  84.         xdef    _DOSBase
  85.         xdef    _IntuitionBase
  86.         xdef    _GfxBase
  87.  
  88.         SECTION  "LIB_SKELL",CODE
  89.  
  90.         lea     dosname(pc),a1
  91.         cldat   d0
  92.         move.l  (_SysBase).w,a6
  93.         libcall OpenLibrary
  94.         tst.l   d0
  95.         beq.s   nolib
  96.         move.l  d0,a6
  97.         libcall Output
  98.         move.l  d0,d1
  99.         move.l  #idString,d2
  100.         move.l  idSize,d3
  101.         libcall Write
  102.         move.l  a6,a1
  103.         move.l  (_SysBase).w,a6
  104.         libcall CloseLibrary
  105. nolib:  moveq   #RETURN_FAIL,d0
  106.         rts
  107.  
  108. ROMTag:
  109.         dc.w    RTC_MATCHWORD
  110.         dc.l    ROMTag
  111.         dc.l    EndCode
  112.         dc.b    RTF_AUTOINIT
  113.         dc.b    VERSION
  114.         dc.b    NT_LIBRARY
  115.         dc.b    0
  116.         dc.l    libraryName
  117.         dc.l    idString
  118.         dc.l    Init
  119. EndCode:
  120.         dc.w    0
  121.  
  122. libraryName:
  123.         dc.b    'tool.library',0
  124.         even
  125. idString:
  126.         dc.b    CR,LF,' tool.library 7.6 (26-Dec-1990) © Copyright 1990 Jaba Development.',CR,LF
  127.         dc.b    ' Written with the Devpac Assembler version 2.14 by Jan van den Baard.',CR,LF,CR,LF,0
  128. idEnd:  even
  129. idSize: dc.l    (idEnd-idString-1)
  130. dosname:
  131.         dc.b    'dos.library',0
  132.         even
  133. intname:
  134.         dc.b    'intuition.library',0
  135.         even
  136. graname:
  137.         dc.b    'graphics.library',0
  138.         even
  139. Init:
  140.         dc.l    tb_SIZEOF
  141.         dc.l    funcTable
  142.         dc.l    dataTable
  143.         dc.l    InitLib
  144.  
  145. funcTable:
  146.         dc.l    OpenLib
  147.         dc.l    CloseLib
  148.         dc.l    ExpungeLib
  149.         dc.l    ExtFuncLib
  150.  
  151.         dc.l    CreatePort
  152.         dc.l    DeletePort
  153.         dc.l    CreateExtIO
  154.         dc.l    DeleteExtIO
  155.         dc.l    CreateStdIO
  156.         dc.l    DeleteStdIO
  157.         dc.l    CreateTimeDelay
  158.         dc.l    DoTimeDelay
  159.         dc.l    DeleteTimeDelay
  160.  
  161.         dc.l    QuickSort
  162.         dc.l    SwapMem
  163.  
  164.         dc.l    TestBits
  165.         dc.l    SelectGadget
  166.         dc.l    DeSelectGadget
  167.         dc.l    MutualExclude
  168.         dc.l    MutualInclude
  169.         dc.l    EraseGadget
  170.         dc.l    GadgetOn
  171.         dc.l    GadgetOff
  172.         dc.l    SelectTest
  173.         dc.l    ShadowGadget
  174.         dc.l    OnGList
  175.         dc.l    OffGList
  176.         dc.l    SelectGList
  177.         dc.l    DeSelectGList
  178.         dc.l    ShadowGList
  179.         dc.l    EraseGList
  180.  
  181.         dc.l    InitMemoryChain
  182.         dc.l    AllocItem
  183.         dc.l    FreeItem
  184.         dc.l    FreeMemoryChain
  185.  
  186.         dc.l    Format
  187.         dc.l    WriteFormat
  188.         dc.l    MatchPattern
  189.         dc.l    Isolate
  190.         dc.l    BstrToCstr
  191.         dc.l    GetDate
  192.  
  193.         dc.l    OpenDir
  194.         dc.l    GetEntry
  195.         dc.l    CloseDir
  196.         dc.l    FreeDir
  197.         dc.l    IoErrToStr
  198.  
  199.         dc.l    AllocFreq
  200.         dc.l    FreeFreq
  201.         dc.l    FileRequest
  202.  
  203.         dc.l    -1
  204.  
  205. dataTable:
  206.         INITBYTE LH_TYPE,NT_LIBRARY
  207.         INITLONG LN_NAME,libraryName
  208.         INITBYTE LIB_FLAGS,LIBF_SUMUSED!LIBF_CHANGED
  209.         INITWORD LIB_VERSION,VERSION
  210.         INITWORD LIB_REVISION,REVISION
  211.         INITLONG LIB_IDSTRING,idString
  212.         dc.l     0
  213.  
  214. InitLib
  215.         move.l  a5,-(sp)
  216.         movea.l d0,a5
  217.         move.l  a0,tb_SegList(a5)
  218.         move.l  a6,tb_SysBase(a5)
  219.         lea     dosname(pc),a1
  220.         cldat   d0
  221.         libcall OpenLibrary
  222.         move.l  d0,_DOSBase
  223.         move.l  d0,tb_DOSBase(a5)
  224.         beq.s   NoDOS
  225.         lea     intname(pc),a1
  226.         cldat   d0
  227.         libcall OpenLibrary
  228.         move.l  d0,_IntuitionBase
  229.         move.l  d0,tb_IntuitionBase(a5)
  230.         beq.s   NoINT
  231.         lea     graname(pc),a1
  232.         cldat   d0
  233.         libcall OpenLibrary
  234.         move.l  d0,_GfxBase
  235.         move.l  d0,tb_GfxBase(a5)
  236.         beq.s   NoGFX
  237.         move.l  a5,d0
  238.         bra.s   Done
  239. NoDOS:  ALERT   AG_OpenLib!AN_DOSLib
  240.         bra.s   Error
  241. NoINT:  move.l  tb_DOSBase(a5),a1
  242.         libcall CloseLibrary
  243.         ALERT   AG_OpenLib!AN_Intuition
  244.         bra.s   Error
  245. NoGFX:  move.l  tb_DOSBase(a5),a1
  246.         libcall CloseLibrary
  247.         move.l  tb_IntuitionBase(a5),a1
  248.         libcall CloseLibrary
  249.         ALERT   AG_OpenLib!AN_GraphicsLib
  250. Error:  cldat   d0
  251. Done:   movea.l (sp)+,a5
  252.         rts
  253.  
  254. OpenLib:
  255.         inc.w   LIB_OPENCNT(a6)
  256.         bclr    #LIBB_DELEXP,LIB_FLAGS(a6)
  257.         move.l  a6,d0
  258.         rts
  259.  
  260. CloseLib:
  261.         cldat   d0
  262.         dec.w   LIB_OPENCNT(a6)
  263.         bne.s   ret
  264.         btst    #LIBB_DELEXP,LIB_FLAGS(a6)
  265.         beq.s   ret
  266.         bsr.s   ExpungeLib
  267. ret:    rts
  268.  
  269. ExpungeLib:
  270.         movem.l d2/a5/a6,-(sp)
  271.         tst.w   LIB_OPENCNT(a6)
  272.         beq.s   NDLex
  273.         bset    #LIBB_DELEXP,LIB_FLAGS(a6)
  274.         cldat   d0
  275.         bra.s   DLex
  276. NDLex:  move.l  a6,a5
  277.         move.l  tb_SysBase(a5),a6
  278.         movea.l tb_DOSBase(a5),a1
  279.         libcall CloseLibrary
  280.         movea.l tb_IntuitionBase(a5),a1
  281.         libcall CloseLibrary
  282.         movea.l tb_GfxBase(a5),a1
  283.         libcall CloseLibrary
  284.         move.l  a5,a1
  285.         libcall Remove
  286.         move.l  tb_SegList(a5),d2
  287.         movea.l a5,a1
  288.         cldat   d0
  289.         move.w  LIB_NEGSIZE(a5),d0
  290.         suba.l  d0,a1
  291.         add.w   LIB_POSSIZE(a5),d0
  292.         libcall FreeMem
  293.         move.l  d2,d0
  294. DLex:   movem.l (sp)+,d2/a5/a6
  295.         rts
  296.  
  297. ExtFuncLib:
  298.         cldat   d0
  299.         rts
  300.  
  301. _DOSBase:       dc.l    0
  302. _IntuitionBase: dc.l    0
  303. _GfxBase:       dc.l    0
  304.  
  305.         end
  306.  
  307.